package cn.com.fssg.platform.modules.engine.util;

import cn.com.fssg.common.vo.DoubleVO;
import io.minio.StatObjectResponse;
import io.minio.messages.Bucket;
import io.minio.messages.Item;
import lombok.SneakyThrows;
import org.springframework.stereotype.Component;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletResponse;
import java.io.File;
import java.io.InputStream;
import java.util.List;

/**
 * MinioUtil
 * @author kinta
 */
@Component
public class MinioUtil {

    public static MinioUtil cur() {
        return null;
    }


    /**
     * 判断bucket是否存在
     *
     * @return
     */
    public boolean existBucket(String name){
        return false;
    };

    /**
     * 判断Object是否存在
     *
     * @return
     */
    public boolean existObject(String objectName){return false;};

    /**
     * 存储桶设置是否支持版本控制
     *
     * @return Boolean
     */
    public Boolean enableVersion(){return false;};

    /**
     * 列出所有存储桶
     *
     * @return
     */
    public List<Bucket> listBuckets(){return null;};

    /**
     * 列出某个存储桶中的所有对象
     *
     * @param bucketName 存储bucket名称
     * @return 存储bucket内文件对象信息
     */
    public List<Item> listObjects(String bucketName){return null;};

    @SneakyThrows
    public DoubleVO<String, String> upload(MultipartFile file, String objectName){return null;};

    /**
     * 计算文件对象名称
     * @param file
     * @return
     */
    public String getObjectName(File file, String objectType){return null;};

    @SneakyThrows
    public DoubleVO<String, String> upload(File file, String objectType){return null;};

    @SneakyThrows
    public DoubleVO<String, String> upload(File file, String objectName, String objectType){return null;};

    /**
     * 上传文件
     *
     * @param
     * @return
     */
    public DoubleVO<String, String> upload(InputStream inputStream, String contentType, String objectName){return null;};

    /**
     * 下载文件
     *
     * @param fileName
     * @return
     */
    public Boolean download(HttpServletResponse response , String fileName, String versionId){return null;};

    /**
     * 下载文件
     *
     * @param fileName
     * @return
     */
    public Boolean download(HttpServletResponse response, String fileName, String versionId, String aliasName){return null;};

    public byte[] download(String fileName, String versionId){return null;};

    public Boolean view(HttpServletResponse response, String fileName, String versionId) {return null;};



    /**
     * 获取对象的元数据
     *
     * @param objectName
     * @return
     */
    public StatObjectResponse statObjectResponse(String objectName){return null;};


    /**
     * 生成一个给HTTP GET请求用的presigned URL
     *
     * @param objectName
     * @param expires   失效时间（以秒为单位），默认是7天，不得大于七天
     * @return
     */
    public String presignedGetObject(String objectName, String versionId, Integer expires, boolean prefixReplace){return null;};

    /**
     * 生成一个给HTTP GET请求用的presigned URL
     *
     * @param objectName
     * @return
     */
    public String presignedGetObject(String objectName){return null;};

}
